--水纹晃动效果

local kernel = {}
kernel.category = "filter"
kernel.name = "water"

kernel.isTimeDependent = true

kernel.vertexData =
{
    {
        name = "xSpeed",
        default = 0.008, 
        min = -1,
        max = 1,
        index = 0,  -- This corresponds to "CoronaVertexUserData.x"
    },
    {
        name = "ySpeed",
        default = 0.005, 
        min = 1,
        max = 100,
        index = 1,  -- This corresponds to "CoronaVertexUserData.y"
    },
}
 
kernel.fragment = [[

    P_COLOR vec4 drawTex(P_UV vec2 uv)
    {
        uv.x+= sin(uv.x*3.14*20. + CoronaTotalTime*3.14*0.5)*CoronaVertexUserData.x;
        uv.y+= sin(uv.y*3.14*20. + CoronaTotalTime*3.14*0.5)*CoronaVertexUserData.y;
        P_UV vec2 new_uv = uv;// + vec2(0.5,0.5);
        P_COLOR vec4 texColor = texture2D( CoronaSampler0, new_uv);


        return texColor;
    }

        P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
    {
        P_UV vec2 uv = texCoord.xy; //- vec2(0.5,0.5) ;
        return CoronaColorScale(drawTex(uv));
    }
]]


if not globalGroup.shaderRecoder[kernel.name] then
    graphics.defineEffect(kernel)
    globalGroup.shaderRecoder[kernel.name] = true
end
